define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'consult.message/index',
        reply_url: 'consult.message/reply',
        delete_url: 'consult.message/delete',
        modify_url: 'consult.message/modify',
        export_url: 'consult.message/export',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                skin:'all',
                toolbar: ['refresh',
                    'delete','export'],
                cols: [[
                    {type: "checkbox"},
                    {field: 'id', width: 80, title: 'ID'},
                    {field: 'type_text', width: 80, search: true, title: '类型'},
                    {field: 'title', minWidth: 80, title: '标题'},
                    {field: 'content', minWidth: 80, search: false, title: '内容'},
                    {field: 'reply', minWidth: 80, search: false, title: '回复内容'},
                    {field: 'reply_time_text', minWidth: 80, search: false, title: '回复时间'},
                    {field: 'username', width: 120, search: false, title: '手机号'},
                    {field: 'township_text', width: 120, selectList:townshipSelect,hide: true, title: '所属乡镇'},
                    {field: 'status', width: 80, title: '状态',selectList: {0:'已回复',1:'未回复'}, templet: function(d){let color='red';if(d.status_text=='已回复'){color='green';}return '<span style="color:'+ color+'">'+d.status_text+'</span>';}},
                    {field: 'create_time', width: 180, title: '创建时间', search: 'range'},
                    {
                        width: 180,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '回复',
                                url: init.reply_url,
                                method: 'open',
                                auth: 'reply',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-window="true"',
                            },],'delete']
                    }
                ]],
            });
            ea.listen();
        },
        reply: function () {
            ea.listen();
        },
    };
    return Controller;
});